package me.lc.linklink.core;

import java.util.Random;

import me.lc.linklink.scene.GameScene;
import me.lc.linklink.util.GameUtil;
import android.widget.Toast;
import java.util.*;

import com.wiyun.game.WiGameAllClient;
import com.wiyun.game.model.ChallengeRequest;

public class MyWiGameAllClient extends WiGameAllClient {

	private Random r = new Random((new Date()).getTime());

	@Override
	public void wyPlayChallenge(ChallengeRequest request) {
		// 开始挑战
		String challengeToUserId = request.getCtuId();
		String challengaId = request.getChallengeDefinitionId();
		// Toast.makeText(GameSystem.AndroidContext,
		// "开始接收用户:" + challengeToUserId + "的挑战", Toast.LENGTH_LONG)
		// .show();

		// TODO 需要判断ID

		StageManager.instance.isChallenge = true;
		StageManager.instance.challengeToUser = challengeToUserId;
		StageManager.instance.challengeScore = request.getScore();
		GameScene.make().startNewTimeGame();
		GameUtil.switchSceneFlipX(GameScene.make());
	}

	@Override
	public void wyChallengeRequestSent() {
		int temp = r.nextInt(300) + 200;
		int coin = temp / 100 * 100;

		StageManager.instance.goldCount += coin;
		StageManager.instance.saveGold();
		Toast.makeText(GameSystem.AndroidContext, "奖励" + coin + "金币!", 5000)
				.show();
	}

}
